Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exited Containers Missing in Docker Compose Status with Custom Config #11827

Open
RabihND opened this issue May 16, 2024 · 4 comments
Open

Exited Containers Missing in Docker Compose Status with Custom Config #11827

RabihND opened this issue May 16, 2024 · 4 comments
Labels

Comments

@RabihND
Copy link

RabihND commented May 16, 2024

Description

I'm encountering an issue where using the -f file path option with --format json and the docker-compose status command does not display exited containers. This behavior seems inconsistent with the expected functionality of displaying all containers managed by Docker Compose, regardless of their current state (running, exited, etc.).

Steps To Reproduce

  1. Create a docker-compose.yml file with services defined.
  2. Run docker compose up -d to start the services in detached mode.
  3. Exit one of the containers manually or let it exit naturally.
  4. Execute docker compose -f /path/to/docker-compose.yml ps --format json or --status=... with removing or dead or exited as mentioned in [A]
  5. Observe that the exited container is not listed in the output.

Expected Behavior

The command with --format and --status options should list all desired containers managed by the specified docker-compose.yml, including those that have exited.

Actual Behavior

Only running containers are displayed in the output. Exited containers are omitted.

Compose Version

Docker Compose version v2.24.5

Docker Environment

Client: Docker Engine - Community
 Version:    25.0.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.5
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 23
  Running: 21
  Paused: 0
  Stopped: 2
 Images: 47
 Server Version: 25.0.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.8.0-31-generic
 Operating System: Ubuntu 24.04 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 20
 Total Memory: 31.02GiB
 Name: **********
 ID: *****************************
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: ****************
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

If this behavior is intended, could you please provide documentation or guidance on how to achieve the desired outcome? If it's a bug, I'd appreciate any insights into potential workarounds or fixes.

Thank you for your attention to this matter.

@ndeloof
Copy link
Contributor

ndeloof commented May 17, 2024

I can't reproduce your issue:

$ docker compose stop web
[+] Stopping 1/1
 ✔ Container avatars-web-1  Stopped                                                                                                                                  0.3s 
$ docker compose ps --status=running --format json
{"Command":"\"flask run --host=0.…\"","CreatedAt":"2024-05-17 08:08:30 +0200 ...
$ docker compose ps --status=exited --status=died --format json
{"Command":"\"docker-entrypoint.s…\"","CreatedAt":"2024-05-17 08:08:30 +0200 ...

Can you please tell me the exact command you're using ?

@RabihND
Copy link
Author

RabihND commented May 21, 2024

Hello;

$ docker ps -a
CONTAINER ID   IMAGE            COMMAND                  CREATED          STATUS                    PORTS                                       NAMES
625242191a1f   docker_metrics   "/bin/sh -c /mnt/met…"   13 seconds ago   Up 12 seconds (healthy)   0.0.0.0:9090->9090/tcp, :::9090->9090/tcp   metrics

$ docker compose stop metrics
[+] Stopping 1/1
 ✔ Container metrics  Stopped    

$ docker compose ps --status=running --format json
$ docker compose ps --status=exited --status=died --format json
$ docker ps -a
CONTAINER ID   IMAGE            COMMAND                  CREATED          STATUS                        PORTS     NAMES
625242191a1f   docker_metrics   "/bin/sh -c /mnt/met…"   59 seconds ago   Exited (137) 22 seconds ago             metrics

It appears that the command docker compose ps --status=exited --status=died --format json isn’t providing any output.

@ndeloof
Copy link
Contributor

ndeloof commented May 21, 2024

please inspect stopped container (docker inspect 625..) and attach output

@RabihND
Copy link
Author

RabihND commented May 22, 2024

Sure!

$ docker inspect 625242191a1f
[
    {
        "Id": "625242191a1f29858266bd4d81a557907741b6fc9bba124657e3f2cd44e3e431",
        "Created": "2024-05-21T20:00:40.840789846Z",
        "Path": "/bin/sh",
        "Args": [
            "-c",
            "/mnt/metrics/metrics_init.sh"
        ],
        "State": {
            "Status": "exited",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": 137,
            "Error": "",
            "StartedAt": "2024-05-22T14:35:51.270337315Z",
            "FinishedAt": "2024-05-22T14:36:11.03386656Z",
            "Health": {
                "Status": "unhealthy",
                "FailingStreak": 0,
                "Log": [
                    {
                        "Start": "2024-05-21T16:00:50.991890648-04:00",
                        "End": "2024-05-21T16:00:51.03218905-04:00",
                        "ExitCode": 0,
                        "Output": "16\n"
                    },
                    {
                        "Start": "2024-05-21T16:01:01.033288143-04:00",
                        "End": "2024-05-21T16:01:01.069622287-04:00",
                        "ExitCode": 0,
                        "Output": "16\n"
                    },
                    {
                        "Start": "2024-05-21T16:01:11.070726056-04:00",
                        "End": "2024-05-21T16:01:11.105185324-04:00",
                        "ExitCode": 0,
                        "Output": "16\n"
                    },
                    {
                        "Start": "2024-05-22T10:36:01.272489742-04:00",
                        "End": "2024-05-22T10:36:01.312613745-04:00",
                        "ExitCode": 0,
                        "Output": "16\n"
                    }
                ]
            }
        },
        "Image": "sha256:387f7ef7d049a85caf047092372dc24efb8ff6f1f5cb8c52196418a803d56866",
        "ResolvConfPath": "/var/lib/docker/containers/625242191a1f29858266bd4d81a557907741b6fc9bba124657e3f2cd44e3e431/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/625242191a1f29858266bd4d81a557907741b6fc9bba124657e3f2cd44e3e431/hostname",
        "HostsPath": "/var/lib/docker/containers/625242191a1f29858266bd4d81a557907741b6fc9bba124657e3f2cd44e3e431/hosts",
        "LogPath": "/var/lib/docker/containers/625242191a1f29858266bd4d81a557907741b6fc9bba124657e3f2cd44e3e431/625242191a1f29858266bd4d81a557907741b6fc9bba124657e3f2cd44e3e431-json.log",
        "Name": "/metrics",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/home/ranop/Desktop/Dev/docker_open5gs/metrics:/mnt/metrics:rw",
                "/etc/timezone:/etc/timezone:ro",
                "/etc/localtime:/etc/localtime:ro"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "docker_open5gs_default",
            "PortBindings": {
                "9090/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "9090"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "ConsoleSize": [
                0,
                0
            ],
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "private",
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": [],
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": null,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware",
                "/sys/devices/virtual/powercap"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/0d73e535df926116ff4eab672dd2830e0132bdc3611467e4aa1442944d668cbe-init/diff:/var/lib/docker/overlay2/sunr3btb4kjm786flk5o4d32l/diff:/var/lib/docker/overlay2/98713dd93e05725da8bfa99496b9a4bdc4f18e74513db5f2bdeb2b5ac2583463/diff",
                "MergedDir": "/var/lib/docker/overlay2/0d73e535df926116ff4eab672dd2830e0132bdc3611467e4aa1442944d668cbe/merged",
                "UpperDir": "/var/lib/docker/overlay2/0d73e535df926116ff4eab672dd2830e0132bdc3611467e4aa1442944d668cbe/diff",
                "WorkDir": "/var/lib/docker/overlay2/0d73e535df926116ff4eab672dd2830e0132bdc3611467e4aa1442944d668cbe/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/home/ranop/Desktop/Dev/docker_open5gs/metrics",
                "Destination": "/mnt/metrics",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/etc/timezone",
                "Destination": "/etc/timezone",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/etc/localtime",
                "Destination": "/etc/localtime",
                "Mode": "ro",
                "RW": false,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "625242191a1f",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": true,
            "AttachStderr": true,
            "ExposedPorts": {
                "9090/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "NSSF_IP=172.22.0.28",
                "BSF_IP=172.22.0.29",
                "NRF_IP=172.22.0.12",
                "UE_IPV4_INTERNET=192.168.100.0/24",
                "SGWC_IP=172.22.0.5",
                "UPF_ADVERTISE_IP=172.22.0.8",
                "SMF_IP=172.22.0.7",
                "UE1_AMF=8000",
                "SCSCF_BIND_PORT=3870",
                "PCSCF_IP=172.22.0.21",
                "MNC=01",
                "SGWU_IP=172.22.0.6",
                "SRS_UE_IP=172.22.0.34",
                "SMSC_IP=172.22.0.33",
                "UDM_IP=172.22.0.13",
                "MONGO_IP=172.22.0.2",
                "PCSCF_BIND_PORT=3871",
                "SMF_DNS2=8.8.4.4",
                "RTPENGINE_IP=172.22.0.16",
                "UE1_IMEISV=4370816125816151",
                "METRICS_IP=172.22.0.36",
                "IPERF3_SERVER_PORT=5202",
                "SCP_IP=172.22.0.35",
                "SGWU_ADVERTISE_IP=172.22.0.6",
                "AMF_IP=172.22.0.10",
                "NR_UE_IP=172.22.0.24",
                "MYSQL_IP=172.22.0.17",
                "SRS_GNB_IP=172.22.0.37",
                "TEST_NETWORK=172.22.0.0/24",
                "MAX_NUM_UE=1024",
                "UE1_KI=8baf473f2f8fd09487cccbd7097c6862",
                "SRS_ENB_IP=172.22.0.22",
                "OSMOHLR_IP=172.22.0.32",
                "UE1_IMEI=356938035643803",
                "SMF_DNS1=8.8.8.8",
                "DNS_IP=172.22.0.15",
                "PYHSS_IP=172.22.0.18",
                "PCRF_IP=172.22.0.4",
                "ICSCF_IP=172.22.0.19",
                "UE_IPV4_IMS=192.168.101.0/24",
                "PCRF_BIND_PORT=3873",
                "DOCKER_HOST_IP=192.168.1.223",
                "MCC=001",
                "UDR_IP=172.22.0.14",
                "ENTITLEMENT_SERVER_IP=172.22.0.30",
                "OAI_ENB_IP=172.22.0.25",
                "UE1_OP=11111111111111111111111111111111",
                "UPF_IP=172.22.0.8",
                "WEBUI_IP=172.22.0.26",
                "NR_GNB_IP=172.22.0.23",
                "AUSF_IP=172.22.0.11",
                "MME_IP=172.22.0.9",
                "OSMOMSC_IP=172.22.0.31",
                "HSS_IP=172.22.0.3",
                "ICSCF_BIND_PORT=3869",
                "PYHSS_BIND_PORT=3875",
                "SCSCF_IP=172.22.0.20",
                "UE1_IMSI=001011234567895",
                "PCF_IP=172.22.0.27",
                "GRAFANA_IP=172.22.0.39",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "DEBIAN_FRONTEND=noninteractive",
                "PROMETHEUS_VERSION=2.40.2"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "/mnt/metrics/metrics_init.sh"
            ],
            "Healthcheck": {
                "Test": [
                    "CMD-SHELL",
                    "/bin/bash -c \"pgrep prometheus\""
                ],
                "Interval": 10000000000,
                "Timeout": 10000000000,
                "Retries": 5
            },
            "Image": "docker_metrics",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "fdbcadf9f7c16ff18697a53467383db07aad150e887d7c05fca684172c396bc7",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.depends_on": "",
                "com.docker.compose.image": "sha256:387f7ef7d049a85caf047092372dc24efb8ff6f1f5cb8c52196418a803d56866",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "docker_open5gs",
                "com.docker.compose.project.config_files": "/home/ranop/Desktop/Dev/docker_open5gs/docker-compose.yaml",
                "com.docker.compose.project.working_dir": "/home/ranop/Desktop/Dev/docker_open5gs",
                "com.docker.compose.service": "metrics",
                "com.docker.compose.version": "2.24.5",
                "org.opencontainers.image.ref.name": "ubuntu",
                "org.opencontainers.image.version": "20.04"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "a3de82d36f64ae177aa5111646952bf716befaceb6a9169f5313f42522aa808b",
            "SandboxKey": "/var/run/docker/netns/a3de82d36f64",
            "Ports": {},
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "docker_open5gs_default": {
                    "IPAMConfig": {
                        "IPv4Address": "172.22.0.36"
                    },
                    "Links": null,
                    "Aliases": [
                        "metrics",
                        "625242191a1f"
                    ],
                    "MacAddress": "",
                    "NetworkID": "bdf7d3c8e7fa66c757c18a44d4c6037c40170c4b56c30d137e68732133a16b4c",
                    "EndpointID": "",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "DriverOpts": null,
                    "DNSNames": [
                        "metrics",
                        "625242191a1f"
                    ]
                }
            }
        }
    }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants